package server;

import java.io.IOException;
import java.sql.SQLException;

import server.conn.admin.AdminConnectionController;
import server.conn.PriceBroadcaster;
import server.conn.user.UserConnectionController;
import server.order.OrderController;
import server.price.PriceController;

public class Server {
	public static final int port = 5000;
	public static final int adminPort = 5050;
	public static final int pricePort = 6000;
	
	private UserConnectionController userConnController;
	private AdminConnectionController adminController;
	private PriceBroadcaster priceBroadcaster;
	
	public Server() throws IOException, SQLException {
		PriceController.getInstance(); // init PriceController
		OrderController.getInstance().fulfillOrders(); // init OrderController
		
		priceBroadcaster = new PriceBroadcaster(pricePort);
		priceBroadcaster.start();

		userConnController = new UserConnectionController(port);
		userConnController.start();
		
		adminController = new AdminConnectionController(adminPort);
		adminController.start();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			//Server server = 
			new Server();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
